import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

import Layout from '../views/layout/index'

const routeMap = [{
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true
  },
  {
    path: "/404",
    component: () => import("@/views/error/index"),
    hidden: true
  },
  {
    path: "/",
    redirect: '/supply',
    component: Layout,
    children: [{
      path: '/supply',
      name: 'supply',
      redirect: '/supply/list',
      component: () => import('@/views/supply/index'),
      meta: {
        title: '货源调度页面',
        icon: 'zyh_supply'
      },
      children: [{
        path: 'list',
        name: 'supplyList',
        component: () => import('@/views/supply/comp/list'),
        meta: {
          title: '数据列表',
          icon: 'zyh_supply'
        },
      }, {
        path: 'timeline',
        name: 'supplyTimeline',
        component: () => import('@/views/supply/comp/timeline'),
        meta: {
          title: '时间轴记录',
          icon: 'zyh_supply'
        },
      }]
    }, {
      path: '/order',
      name: 'order',
      redirect: '/order/list',
      component: () => import('@/views/order/index'),
      meta: {
        title: '订单管理',
        icon: 'zyh_order'
      },
      children: [{
        path: 'list',
        name: 'orderList',
        redirect: '/order/list/v1',
        component: () => import('@/views/order/list/index'),
        meta: {
          title: '订单列表',
          icon: 'zyh_order'
        },
        children: [{
          path: 'v1',
          name: 'orderListData',
          component: () => import('@/views/order/list/comp/list'),
          meta: {
            title: '数据列表',
            icon: 'zyh_order'
          },
        }, {
          path: 'detail',
          name: 'orderListItemDetail',
          component: () => import('@/views/order/list/comp/detail'),
          meta: {
            title: '订单详情',
            icon: 'zyh_order'
          },
        }]
      }, {
        path: 'income',
        name: 'income',
        component: () => import('@/views/order/income/index'),
        meta: {
          title: '收入统计',
          icon: 'zyh_order'
        },
      }, {
        path: 'performance',
        name: 'performance',
        component: () => import('@/views/order/performance/index'),
        meta: {
          title: '业绩统计',
          icon: 'zyh_order'
        },
      }, {
        path: 'charge',
        name: 'charge',
        component: () => import('@/views/order/charge/index'),
        meta: {
          title: '会员收费管理',
          icon: 'zyh_order'
        },
      }]
    }, {
      path: '/consumer',
      name: 'consumer',
      redirect: '/consumer/list',
      component: () => import('@/views/consumer/index'),
      meta: {
        title: '消费记录',
        icon: 'zyh_consumer'
      },
      children: [{
        path: 'list',
        name: 'consumerList',
        component: () => import('@/views/consumer/comp/list'),
        meta: {
          title: '消费列表',
          icon: 'zyh_consumer'
        },
      }, {
        path: 'detail',
        name: 'consumerDetail',
        component: () => import('@/views/consumer/comp/detail'),
        meta: {
          title: '订单详情',
          icon: 'zyh_consumer'
        },
      }]
    }, {
      path: '/distribution',
      name: 'distribution',
      redirect: '/distribution/list',
      component: () => import('@/views/distribution/index'),
      meta: {
        title: '分销管理',
        icon: 'zyh_distribution'
      },
      children: [{
        path: 'list',
        name: 'distributionList',
        component: () => import('@/views/distribution/list/index'),
        meta: {
          title: '分销商管理',
          icon: 'zyh_distribution'
        },
      }, {
        path: 'earnings',
        name: 'earnings',
        component: () => import('@/views/distribution/earnings/index'),
        meta: {
          title: '分销收益',
          icon: 'zyh_distribution'
        },
      }, {
        path: 'cashout',
        name: 'cashout',
        component: () => import('@/views/distribution/cashout/index'),
        meta: {
          title: '提现列表',
          icon: 'zyh_distribution'
        },
      }, {
        path: 'grade',
        name: 'grade',
        component: () => import('@/views/distribution/grade/index'),
        meta: {
          title: '分销等级',
          icon: 'zyh_distribution'
        },
      }, {
        path: 'setting',
        name: 'setting',
        component: () => import('@/views/distribution/setting/index'),
        meta: {
          title: '分销设置',
          icon: 'zyh_distribution'
        },
      }]
    }, {
      path: '/member',
      name: 'member',
      redirect: '/member/list',
      component: () => import('@/views/member/index'),
      meta: {
        title: '用户管理',
        icon: 'zyh_member'
      },
      children: [{
        path: 'list',
        name: 'memberList',
        component: () => import('@/views/member/list/index'),
        meta: {
          title: '系统用户',
          icon: 'zyh_member'
        },
      }, {
        path: 'client',
        name: 'client',
        component: () => import('@/views/member/client/index'),
        meta: {
          title: '客户管理',
          icon: 'zyh_member'
        },
      }, {
        path: 'weixin',
        name: 'weixin',
        component: () => import('@/views/member/weixin/index'),
        meta: {
          title: '微信群管理',
          icon: 'zyh_member'
        },
      }, {
        path: 'norelate',
        name: 'norelate',
        component: () => import('@/views/member/norelate/index'),
        meta: {
          title: '未关联好友',
          icon: 'zyh_member'
        },
      }]
    }, {
      path: '/database',
      name: 'database',
      redirect: '/database/list',
      component: () => import('@/views/database/index'),
      meta: {
        title: '数据筛选',
        icon: 'zyh_database'
      },
      children: [{
        path: 'list',
        name: 'databaseList',
        component: () => import('@/views/database/comp/list'),
        meta: {
          title: '数据筛选',
          icon: 'zyh_database'
        },
      }]
    }, {
      path: '/timeline',
      name: 'timeline',
      redirect: '/timeline/list',
      component: () => import('@/views/timeline/index'),
      meta: {
        title: '时间轴操作记录',
        icon: 'zyh_timeline'
      },
      children: [{
        path: 'list',
        name: 'timelineList',
        component: () => import('@/views/timeline/comp/list'),
        meta: {
          title: '时间轴',
          icon: 'zyh_timeline'
        },
      }, {
        path: 'log',
        name: 'timelineLog',
        component: () => import('@/views/timeline/comp/log'),
        meta: {
          title: '操作记录',
          icon: 'zyh_timeline'
        },
      }, {
        path: 'detail',
        name: 'timelineDetail',
        component: () => import('@/views/timeline/comp/detail'),
        meta: {
          title: '货源详情',
          icon: 'zyh_timeline'
        },
      }]
    }, {
      path: '/protocol',
      name: 'protocol',
      redirect: '/protocol/v1',
      component: () => import('@/views/protocol/index'),
      meta: {
        title: '协议管理',
        icon: 'zyh_protocol'
      },
      children: [{
        path: ':id',
        name: 'protocolContent',
        component: () => import('@/views/protocol/comp/content'),
        meta: {
          title: '协议',
          icon: 'zyh_protocol'
        },
      }]
    }]
  },
  /*  {
     path: "*",
     redirect: "/404",
     hidden: true
   } */
];

export default new Router({
  scrollBehavior: () => ({
    y: 0
  }),
  routes: routeMap
});
